#ifndef __SM4_H__
#define __SM4_H__

#include <stdint.h>

#ifdef __cplusplus
extern "C"
{
#endif

#if !defined(inline) && !defined(__cplusplus)
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define sm4_inline inline
#elif defined(__GNUC__) && __GNUC__ >= 2
#define sm4_inline __inline__
#elif defined(_MSC_VER)
#define sm4_inline __inline
#else
#define sm4_inline
#endif
#else
#define sm4_inline inline
#endif

#ifdef __cplusplus
}
#endif

#define SM4_ENCRYPT 1
#define SM4_DECRYPT 0

#define SM4_BLOCK_SIZE   16
#define SM4_KEY_SCHEDULE 32

typedef struct SM4_KEY_st
{
    uint32_t rk[SM4_KEY_SCHEDULE];
} SM4_KEY;

int SM4_set_key(const uint8_t *key, SM4_KEY *ks);

void SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);

void SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);

#endif /* __SM4_H__ */
